//
//  HEDocOrderAddressCell.m
//  HealthElderly
//
//  Created by 吴欧 on 2021/5/13.
//  Copyright © 2021 honglutec. All rights reserved.
//

#import "HEDocOrderAddressCell.h"

@interface HEDocOrderAddressCell ()

@property(nonatomic, strong) UILabel *nameLb;
@property(nonatomic, strong) UILabel *phoneLb;
@property(nonatomic, strong) UILabel *addressLb;

@end

@implementation HEDocOrderAddressCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        [self initUI];
    }
    return self;
}

- (void)initUI {
    UIView *warp = [UIView new];
    warp.layer.borderWidth = 1;
    warp.layer.borderColor = CNavSubTitleColor.CGColor;
    warp.layer.cornerRadius = 8;
    [self.contentView addSubview:warp];
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(addBtnClick)];
    [warp addGestureRecognizer:tap];
  
    [warp mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).mas_offset(15);
        make.left.equalTo(self.contentView).mas_offset(15);
        make.right.equalTo(self.contentView).mas_offset(-15);
        make.bottom.equalTo(self.contentView).mas_offset(-5);
    }];
    
    _nameLb = [UILabel new];
    _nameLb.font = DYBlodFont(17);
    _nameLb.text = @"-";
    _nameLb.textColor = CNavLightBlackColor;
    [warp addSubview:_nameLb];
    
    _phoneLb = [UILabel new];
    _phoneLb.font = DYFont(17);
    _phoneLb.text = @"-";
    _phoneLb.textColor = CNavLightBlackColor;
    [warp addSubview:_phoneLb];
    
    _addressLb = [UILabel new];
    _addressLb.font = DYFont(16);
    _addressLb.text = @"-";
    _addressLb.textColor = CNavDargGrayColor;
    _addressLb.numberOfLines = 0;
    [warp addSubview:_addressLb];
    
    [_nameLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(warp).mas_offset(15);
        make.left.equalTo(warp).mas_offset(15);
    }];
    [_nameLb setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];

    [_phoneLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(warp).mas_offset(15);
        make.left.equalTo(_nameLb.mas_right).offset(5);
        make.right.equalTo(warp).mas_offset(-15);
    }];
    
    [_addressLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_nameLb.mas_bottom).mas_offset(10);
        make.left.equalTo(_nameLb.mas_left);
        make.right.equalTo(warp).mas_offset(-15);
        make.bottom.equalTo(warp).mas_offset(-15);
    }];
}

- (void)configCellWithModel:(id)model fiterModel:(GDFiterCellModel *)fiterModel indexPath:(NSIndexPath *)indexPath {
    _delegate = self.formModel.proxyVC;
    _nameLb.text = self.formModel.order_addres.name;
    _phoneLb.text = self.formModel.order_addres.phoneNumber;
    _addressLb.text = [NSString stringWithFormat:@"%@%@", self.formModel.order_addres.KTitleString, IsNotNull(self.formModel.order_addres.detailAddress)];
}

- (void)addBtnClick {
    if ([self.delegate respondsToSelector:@selector(orderSelectAddressSelect)]) {
        [_delegate orderSelectAddressSelect];
    }
}
 
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

@end

